package com.yungu.swift.schedule.service.impl;

import com.alibaba.dubbo.config.annotation.Reference;
import com.yungu.swift.assets.driver.service.DriverWorkTimeService;
import com.yungu.swift.lbs.model.dto.DriverWorkTimeDto;
import com.yungu.swift.lbs.service.LocationService;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * @author huangjx
 * @date 2017/7/24
 */
@Slf4j
@Service
public class DriverStaticWorkTimeService {
    private static final Logger logger = LoggerFactory.getLogger(DriverStaticWorkTimeService.class);

    @Reference
    private DriverWorkTimeService driverWorkTimeService;
    @Reference
    private LocationService locationService;


    public void insertWorkTime() {
        logger.info("--------------------------------------------统计工时任务开始---------------------------------------");
        List<DriverWorkTimeDto> workTimeList = locationService.getWorkTimeList().getData();
        if (workTimeList != null) {
            for (DriverWorkTimeDto dto : workTimeList) {
                driverWorkTimeService.add(dto);
                log.info(dto.toString());
            }
        }
        logger.info("--------------------------------------------统计工时任务结束---------------------------------------");
    }
}
